package com.example.musicplayer.square;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.example.musicplayer.R;

public class Square_man extends AppCompatActivity {
    private SQLiteDatabase db;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.square_man);
        TextView name=(TextView)findViewById(R.id.te_name);
        TextView sex=(TextView)findViewById(R.id.te_sex);
        TextView age=(TextView)findViewById(R.id.te_age);
        TextView gao=(TextView)findViewById(R.id.te_gao);
        TextView aihao=(TextView)findViewById(R.id.te_aihao);


        DBMAN DBMAN = new DBMAN(this);
        db = DBMAN.getWritableDatabase();
        //获取输入的ID值
        Bundle bundle=this.getIntent().getExtras();
        String str= bundle.getString("text");

        //使用游标进行逐行查找
        Cursor cursor = db.rawQuery("select * from Student where id = ?",new String[]{str});
        while (cursor.moveToNext()) {
            int id = cursor.getInt(0);
            if (id == Integer.parseInt(str)) {
                name.setText(cursor.getString(1));
                sex.setText(cursor.getString(2));
                age.setText(cursor.getString(3));
                gao.setText(cursor.getString(4));
                aihao.setText(cursor.getString(5));
            }
        }

    }


}